/*****************************************************************
Wowengine - v0.1

File: wen_input.h
Creation date: 2009-08-05
*****************************************************************/

/****************************************************************/
#ifndef WEN_INPUT_H
#define WEN_INPUT_H
//----------------------------------------------------------------
#include "system/wen_system.h"
/****************************************************************/

namespace wen
{
//----------------------------------------------------------------
class WEN_API Input
{
	//////////////////////////////////////////////////////
	// TO-DO: Input has to be a singleton!!!!
	//////////////////////////////////////////////////////

protected:

	// keyboard buffers
	unsigned char m_aucKeyBuffer[256];
	unsigned char m_aucKeyPrevBuffer[256];
	unsigned char m_aucKeyEvent[256];

	// mouse position
	long m_alMouseScreenAbsPos[3];
	long m_alMouseRelPos[3];

	// mouse buttons
	unsigned char m_aucMouseBut[3];
	bool m_abMouseButClick[3];
	bool m_abButState[3];

	// Update
	void UpdateMouse();
	void UpdateKeyboard();

	// constructor
	Input();

public:

	enum
	{
		POS_X,
		POS_Y,
		POS_Z
	};

	enum MouseButton
	{
		MB_1,
		MB_2,
		MB_3
	};

	enum KeyState
	{
		KS_NONE,
		KS_DOWN,
		KS_UP
	};

	// destructor
	virtual ~Input();

	virtual bool Init() = 0;
	virtual void Update() = 0;
	virtual void Deinit() = 0;
    
	// devices acquisition
	virtual void Acquire() = 0;
	virtual void Reacquire() = 0;
	virtual void Unacquire() = 0;

	void SetMousePos(long lPosX, long lPosY, long lPosZ);
	void EventClean();
	virtual void Reset();

	// accessors
	inline bool GetKeyDown(unsigned int uiKeyID);
	inline bool GetKeyEventDown(unsigned int uiKeyID);
	inline bool GetKeyEventUp(unsigned int uiKeyID);

	inline bool GetMouseBut(unsigned int uiButID);
	inline bool GetMouseClick(unsigned int uiButID);
	inline long GetMouseScrAbsPos(unsigned int uiButID);
	inline long GetMouseRelPos(unsigned int uiButID);
};
/****************************************************************/
#include "wen_input.inl"
/****************************************************************/

//----------------------------------------------------------------
} // end namespace
//----------------------------------------------------------------
#endif // WEN_INPUT_H
//----------------------------------------------------------------